package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	// 测试加密数据
	encryptedData := "6iiUpyY8eDvNuOqmSxJFQ1VCXlFdVRIKElFUXVleEhwSQFBARk5dQlQbAhVAUUNDR19CVAECAxJN"
	
	// 创建请求数据
	requestData := map[string]interface{}{
		"data": encryptedData,
	}
	
	// 转换为JSON
	jsonData, err := json.Marshal(requestData)
	if err != nil {
		fmt.Printf("JSON marshal error: %v\n", err)
		return
	}
	
	fmt.Printf("Request JSON: %s\n", string(jsonData))
	
	// 发送请求
	resp, err := http.Post("http://localhost:8080/api/login", "application/json", bytes.NewBuffer(jsonData))
	if err != nil {
		fmt.Printf("HTTP error: %v\n", err)
		return
	}
	defer resp.Body.Close()
	
	// 读取响应
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Printf("Read error: %v\n", err)
		return
	}
	
	fmt.Printf("Status: %d\n", resp.StatusCode)
	fmt.Printf("Response: %s\n", string(body))
}
